<!DOCTYPE html>
<html lang="zh-CN">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>清除浮动-父级添加双伪元素</title>
    <style>
        .clearfix:before,/* 在前面添加一个盒子 */
        .clearfix:after/* 在后面添加一个盒子 */ {
            /* 更符合闭合浮动概念 */
            content: "";
            display: table;
        }

        .clearfix:after {
            clear: both;
            /* 核心语句清除 */
        }

        .clearfix {
            *zoom: 1;
            /* CSS为了兼容IE6、7的写法，比较固定代码意思是IE6、7时候清除浮动 */
        }

        .box {
            width: 800px;
            border: 1px solid blue;
            margin: 0 auto;
        }

        .damao {
            float: left;
            width: 300px;
            height: 200px;
            background-color: azure;
        }

        .ermao {
            float: left;
            width: 200px;
            height: 200px;
            background-color: bisque;
        }

        .footer {
            height: 200px;
            background-color: black;
        }
    </style>
</head>

<body>
    <div class="box clearfix">
        <div class="damao">大毛</div>
        <div class="ermao">二毛</div>
    </div>
    <div class="footer"></div>
    <img src="img/清除浮动-父级添加双伪元素1.png" alt=""><br>
    <img src="img/清除浮动-父级添加双伪元素2.png" alt="">
    </body>

</html>